def open_txt(txt_path):
    with open(txt_path, 'r') as file:
        content = file.read()
    return content


def save_txt(txt_path, content):
    with open(txt_path, 'a') as file:
        file.write(content)


newsText = open_txt(txt_path='news.txt')

# 使用 str.replace() 方法替换掉NBSP非断行空格（Non-Breaking Space），其 Unicode 编码为 \u00A0。
cleaned_text = newsText.replace(u'\u00A0', u' ')

print(cleaned_text)

save_txt(txt_path='newsPreprocess.txt', content=cleaned_text)